using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using DataContext;

namespace BusinessLogic
{
	public class UserBusiness
    {
        #region Field
        UserContext userContext = new UserContext();
        #endregion

        #region Constructors
        public UserBusiness() {}
		#endregion

		#region Business Methods     
        /// <summary>
        /// Check Login
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns>#0: Success</returns>
        public int CheckLogin(string userName, string password)
        {
            try
            {
                return userContext.CheckLogin(userName, password);
            }
            catch (System.Exception)
            {
                return 0;
            }
        }

        /// <summary>
        /// Check Exists UserName
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>#0: Exists; 0: Didn't Exists</returns>
        public int CheckExistsUserName(string userName)
        {
            try
            {
                return userContext.CheckExistsUserName(userName);
            }
            catch (System.Exception)
            {
                return 0;
            }
        }

        /// <summary>
        /// Check Exists Email
        /// </summary>
        /// <param name="email"></param>
        /// <returns>#0: Exists; 0: Didn't Exists</returns>
        public int CheckExistsEmail(string email)
        {
            try
            {
                return userContext.CheckExistsEmail(email);
            }
            catch (System.Exception)
            {
                return 0;
            }
        }
        
        /// <summary>
        /// Update User Status
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public bool UpdateStatus(int userID)
        {
            try
            {
                return userContext.UpdateStatus(userID);
            }
            catch (System.Exception)
            {
                return false;
            }
        }
		#endregion
	}
}
